package cn.earl.springboot.entity;

import java.io.File;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.validator.constraints.NotBlank;

import com.alibaba.fastjson.annotation.JSONField;

/**
 * 帖子
 * 
 * @author ASUS-A455L
 *
 */
@Entity
@Table(name = "tb_post")
public class Post {

	@Id
	@GeneratedValue
	private int id;

	@OneToOne(targetEntity = User.class)
	@JoinColumn(name = "user_id")
	private int user_id;

	// 用户名
	// @OneToOne(targetEntity = User.class)
	// @JoinColumn(referencedColumnName = "username")
	// private String username;

	// 创建时间
	@JSONField(format = Global.DATE_FORMAT)
	private Date posting_time;

	@Transient // 排除这个属性，不插入数据库
	private File picture;
	private String picture_url;

	// 标题
	@NotBlank
	private String title;

	// 内容
	@NotBlank
	private String content;

	// 点赞
	private int praise;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getUser_id() {
		return user_id;
	}

	public void setUser_id(int user_id) {
		this.user_id = user_id;
	}

	public Date getPosting_time() {
		return posting_time;
	}

	public void setPosting_time(Date posting_time) {
		this.posting_time = posting_time;
	}

	public File getPicture() {
		return picture;
	}

	public void setPicture(File picture) {
		this.picture = picture;
	}

	public String getPicture_url() {
		return picture_url;
	}

	public void setPicture_url(String picture_url) {
		this.picture_url = picture_url;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public int getPraise() {
		return praise;
	}

	public void setPraise(int praise) {
		this.praise = praise;
	}

}
